package com.cy.pj.sys.web.controller;

import com.cy.pj.sys.pojo.BlogType;
import com.cy.pj.sys.service.BlogTypeService;
import com.cy.pj.sys.common.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/blog/")
public class BlogTypeController {
    @Autowired
    private BlogTypeService blogTypeService;
    @GetMapping
    public JsonResult doSelectBlogs(BlogType blogType){
        return new JsonResult(blogTypeService.selectBlogs(blogType));
    }
    @GetMapping("id")
    public JsonResult doSelectById(@PathVariable Long id){
        return new  JsonResult(blogTypeService.selectById(id));
    }
    @PostMapping
    public JsonResult doInsertBlog(@RequestBody BlogType blogType){

        blogTypeService.insertBlog(blogType);
        return new JsonResult("insert ok");
    }
    @PutMapping()
    public JsonResult doUpdateBlog(@RequestBody BlogType blogType){
        blogTypeService.updateBlog(blogType);
        return new JsonResult("update ok");
    }
    @DeleteMapping("id")
    public JsonResult doDeleteById(@PathVariable Long...id ){
        blogTypeService.deleteById(id);
        return new JsonResult("delete ok");
    }
}
